package com.boot.datademo2.controller;

import com.boot.datademo2.controller.model.UserRegisterRequest;
import com.boot.datademo2.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 接收注册信息，返回注册结果status
 **/
@RestController
public class UserController {

   @Autowired
    private RegisterService registerService;

   @PostMapping("/register")
    public Map<String,Object> register(@RequestBody UserRegisterRequest userRegisterRequest){             //接收注册提交的user信息
       int registerStatus = registerService.getRegisterStatus(userRegisterRequest);
       Map<String,Object> map = new HashMap<>();
       map.put("registerStatus", registerStatus);//调用service方法校验，得到注册结果status类
       return map;                //返回注册结果status类
   }
}
